<?php
/**
 * @name /www/unit-tests/User.php
 * @author
 * @version 2011.04.2
 *
 * handling changes to user information
 */

// Sets up configuration settings and includes libraries.
require_once('_ini.php');
// Libraries
ReqLib('/lib/private/Orphanage.php');

$OrphanageId = $_POST['OrphanageId'];
$Name = $_POST['Name'];
$ContactFirstName = $_POST['ContactFirstName'];
$ContactLastName = $_POST['ContactLastName'];
$ContactPhoneNumber = $_POST['ContactPhoneNumber'];
$Street1 = $_POST['Street1'];
$Street2 = $_POST['Street2'];
$Street3 = $_POST['Street3'];
$City = $_POST['City'];
$State = $_POST['State'];
$Country = $_POST['Country'];
$PostalCode = $_POST['PostalCode'];
$Notes = $_POST['Notes'];

$Action = $_POST['Action'];


if($Action=="Update Orphanage Info")
{
	$o = new Orphanage();

	$o->Load($OrphanageId);

	$o->Name = $Name;
	$o->ContactFirstName = $ContactFirstName;
	$o->ContactLastName = $ContactLastName;
	$o->ContactPhoneNumber = $ContactPhoneNumber;
	$o->Street1 = $Street1;
	$o->Street2 = $Street2;
	$o->Street3 = $Street3;
	$o->City = $City;
	$o->State = $State;
	$o->Country = $Country;
	$o->PostalCode = $PostalCode;
	$o->Notes = $Notes;

	$o->save();

?>
	<script language="javascript">
		if(window.confirm("Orphanage information has been added successfully.\nDo you want to update more orphanage information?"))
			document.location.replace("orphanages.php");
		else
			document.location.replace("account.php");
	</script>
<?
}

else if($Action=="Delete Orphanage")
{
	$o = new Orphanage();

	$o->Delete($OrphanageId);
?>
	<script language="javascript">
		if(window.confirm("This Orphanage has been deleted successfully.\nDo you want to delete more orphanage?"))
			document.location.replace("orphanages.php");
		else
			document.location.replace("account.php");
	</script>
<?
}
	//php code for other actions will go here
?>

